home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1036 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  2.1 KB

  1. From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
  2. Date: Fri, 18 Feb 94 10:36:38 +0100
  3. Message-Id: <9402180936.AA05169@issan.informatik.uni-dortmund.de>
  4. To: mint@atari.archive.umich.edu
  5. Subject: MiNT 1.10: bugs in nalloc/nfree/kmalloc
  6.  
  7. nalloc2.c:
  8. - nfree: decrement fb over header before testing for NKMAGIC. This
  9. worked before by pure coincidence, because kmalloc always stashes
  10. NKMAGIC into the first two longs of the memory returned by nalloc.
  11. - nfree: when looking for the arena compare with the correct bounds.
  12. - nalloc: always put NKMAGIC into the b_next field of the header so
  13. that nfree can find it.
  14.  
  15. util.c:
  16. - kmalloc: the size of the region passed to nalloc_arena_add is really
  17. two longs smaller!
  18.  
  19. --- orig/nalloc2.c    Wed Feb  9 21:22:52 1994
  20. +++ nalloc2.c    Thu Feb 17 21:40:36 1994
  21. @@ -115,13 +115,13 @@
  22.              b->b_next = mb->b_next;
  23.              *q = b;
  24.              mb->b_size = size;
  25. -            mb->b_next = (struct block *)NKMAGIC;
  26.          }
  27.          else {
  28.              /* not big enough to cut: unlink this from free list */
  29.              NALLOC_DEBUG('w');
  30.              *q = mb->b_next;
  31.          }
  32. +        mb->b_next = (struct block *)NKMAGIC;
  33.          return (void *)(mb+1);
  34.          }
  35.      }
  36. @@ -186,17 +186,18 @@
  37.      struct block *fb = (struct block *)start;
  38.  
  39.      NALLOC_DEBUG('F');
  40. +    /* set fb (and b) to header start */
  41. +    b = --fb;
  42. +
  43.      if (fb->b_next != (struct block *)NKMAGIC) {
  44.      FATAL("nfree: block %lx not allocated by nalloc!",fb);
  45.      }
  46.  
  47. -    /* set fb (and b) to header start */
  48. -    b = --fb;
  49. -
  50.      /* the arena this block lives in */
  51.      for (a = *(qa = &a_first); a; a = *(qa = &a->a_next)) {
  52. -    if ((unsigned long)b > (unsigned long)a &&
  53. -        (unsigned long)b < (((unsigned long)a) + a->a_size)) goto found;
  54. +    if ((unsigned long)b >= (unsigned long)(a+1) &&
  55. +        (unsigned long)b < (((unsigned long)(a+1)) + a->a_size))
  56. +      goto found;
  57.      }
  58.      FATAL("nfree: block %lx not in any arena!",fb);
  59.  
  60. --- orig/util.c    Wed Sep 15 02:44:12 1993
  61. +++ util.c    Thu Feb 17 20:50:10 1994
  62. @@ -158,7 +158,7 @@
  63.          lp = (long *)m->loc;
  64.          *lp++ = (long)KMAGIC;
  65.          *lp++ = (long)m;
  66. -#if 0
  67. +#if 1
  68.          nalloc_arena_add((void *)lp,KERMEM_SIZE - 2*SIZEOF(long));
  69.  #else
  70.          nalloc_arena_add((void *)lp,KERMEM_SIZE);
  71.